import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/rb-oem/oem/ticket/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/rb-oem/oem/ticket/add',
    method: 'post',
    data: row
  })
}

export const getDetail = (params) => {
  return request({
    url: '/api/rb-oem/oem/ticket/info',
    method: 'get',
    params: {
      ...params
    }
  })
}

export const addMerchant = (row) => {
  return request({
    url: '/api/rb-oem/oem/ticket/addMerchant',
    method: 'post',
    data: row
  })
}

export const delMerchant = (params) => {
  return request({
    url: '/api/rb-oem/oem/ticket/delMerchant',
    method: 'get',
    params: {
      ...params
    }
  })
}

export const merchantList = (current, size, params) => {
  return request({
    url: '/api/rb-oem/oem/ticket/merchantList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

/* 批量导入模板 */
export const getExportTemplate = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-oem/oem/ticket/export-template',
    method: 'get',
    params: {
      ...params
    }
  })
}

/* 批量入库 */
export const uploadFile = (file, type, param) => {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('type', type);
  formData.append('id', param.id);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/rb-oem/oem/ticket/import',
    method: 'post',
    data: formData
  })
}